/*
 * LRSExceptions.java
 *
 * Created on April 26, 2006, 3:54 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.genITeam.ria.exception;

/**
 * 
 * @author 05030022
 */
public class NGFException extends Exception {
	static final long serialVersionUID = -3387516993124229948L;
	String errorMessages = "";

	Exception nestedException = null;

	/** Creates a new instance of LRSExceptions */
	public NGFException() {
		super();
	}

	public NGFException(String errorMessage) {
		super(errorMessage);
		parseMessage(errorMessage);
	}

	public NGFException(Exception e) {
		parseMessage(e.getMessage());
		nestedException = e;
	}

	public void addErrorMessage(String error) {
		parseMessage(error);
	}

	public String getErrorMessage() {
		return errorMessages;
	}

	private void parseMessage(String message) {

		message = message.toLowerCase();
		System.out.println("\n\n\n\n Exception Message = " + message);
		if (message.startsWith(" error message coem here from constants")) {
			errorMessages = "error message coem here from constants";
		}else if (message.startsWith("JDBC")) {
			System.out.println("\n\n\n\n Exception Message = " + message);
			errorMessages = "Database Connection not available";
		}else if (message.startsWith("Recepient")) {
			System.out.println("\n\n\n\n Exception Message = " + message);
			errorMessages = message;
		}else if (message.startsWith("for input string")) {
			errorMessages =  "Record Not Found ";
		}else{
			errorMessages = "General error " + message;
		} // end if

	}

}
